package com.freeman.boot;

import com.taobao.api.DefaultTaobaoClient;
import com.taobao.api.TaobaoClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
public class SpringBootDemoApplication {

    @Value("${top.serverUrl}")
    private String serverUrl;
    @Value("${top.appKey}")
    private String appKey;
    @Value("${top.appSecret}")
    private String appSecret;

    @Bean
    public TaobaoClient createClient() {
        return new DefaultTaobaoClient(this.serverUrl, this.appKey, this.appSecret);
    }

    public static void main(String[] args) {

        SpringApplication application = new SpringApplication(SpringBootDemoApplication.class);
        application.setBannerMode(Banner.Mode.CONSOLE);
        application.run(args);
    }
}
